<?php
	include_once("inc/conn.php");
    include_once("inc/function.php");
    
    $userid = intval($_GET['id']);
    $Email = str_check($_GET['mail']);
    $BindType = $_GET['t'];
    $Code = $_GET['code'];
    
    if($BindType == "bind")
    {
		if($Code != md5($userid . "bind" . $Email . $web_pwd_encrypt_prefix))
		{
			echo "error";
			exit;
		}
		$sql = "update users set email = '{$Email}',is_check_email = 1 where id = '{$userid}'";
		$result =  $db->query($sql);
		echo "ok!";
    }
    else
    {
		if($Code != md5($userid . "unbind" . $web_pwd_encrypt_prefix))
		{
			echo "error";
			exit;
		}
		$sql = "update users set is_check_email = 0 where id = '{$userid}'";
		$result =  $db->query($sql);
		echo "ok!";
    }
?>
